<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>表单验证</title>
<style>
	.has-error{
		color:#f00;
		border-bottom:1px solid #f00;
	}
	
	.all-error{
		background:#ffeba6;
		border: 3px solid #f00;
		padding: 8px;
		margin:16px;
	}
</style>
</head>
<body>
	<h1>表单验证</h1>
	<form:form method="POST" modelAttribute="user" action="/userr/valid">
		<form:errors path="*" element="div" cssClass="all-error"/>
		<table>
			<tr>
				<td>编号:</td>
				<td><form:input path="id"/></td>
				<td><form:errors path="id" cssClass="has-error"/></td>
				<td></td>
			</tr>
			<tr>
				<td>姓名:</td>
				<td><form:input path="name" /></td>
				<td><form:errors path="name" cssClass="has-error"/></td>
				<td>必须填写,长度在3~20之间</td>
			</tr>
			<tr>
				<td>年龄:</td>
				<td><form:input path="age" /></td>
				<td><form:errors path="age" cssClass="has-error"/></td>
				<td>必须填写,在16~56</td>
			</tr>
			<tr>
				<td>地址:</td>
				<td><form:input path="addr" /></td>
				<td><form:errors path="addr" cssClass="has-error"/></td>
				<td>必须填写,长度必须超过4个字</td>
			</tr>
			<tr>
				<td colspan="3"><input type="submit" value="验证"></td>
			</tr>
		</table>
	</form:form>
	
</body>
</html>